﻿/**
new RadioBoxGroup({
'id':'box1',call:function(){},
'field':{'name':'networkType','value':'退网'},
'group':[{'value':'退网','text':'退网&nbsp;'},{'value':'转网','text':'转网&nbsp;'},{'value':'新装','text':'新装&nbsp;'}]
});
*/
var RadioBoxGroupMap={};
function RadioBoxGroup(json)
{
	var container=document.getElementById(json.id);
	var field=json.field;
	var boxName=field.name,boxValue=field.value;
	var fieldInput=document.createElement("input");
	fieldInput.id=boxName;
	fieldInput.name=boxName;
	fieldInput.type="hidden";
	fieldInput.value=boxValue;
	container.appendChild(fieldInput);
	RadioBoxGroupMap[boxName]=this;
	var group=json.group;
	var boxs=[],hasChecked=false;
	for(var i=0;i<group.length;i++)
	{
		var item=group[i];
		var box=document.createElement("input");
		box.type="radio";
		box.value=item.value;
		box.name=boxName+"_radio_box_group";
		container.appendChild(box);
		if(boxValue.indexOf(item.value)>=0){box.checked=true;hasChecked=true;}
		boxs.push(box);
		var textNode=document.createElement("label");
		textNode.innerHTML=item.text;
		container.appendChild(textNode);
		box.onclick=function()
		{
			fieldInput.value=this.value;
			if(typeof(json.call)=="function"){json.call(this.value);}
		}
	}
	if(!hasChecked){boxs[0].checked=true;}
	if(typeof(json.call)=="function"){json.call(boxValue);}
}

